package com.hc.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hc.service.UserService;
import com.hc.serviceimp.UserServiceImpl;



@WebServlet("/Login")
public class Login extends HttpServlet {
	//获取service层对象
	UserService us = new UserServiceImpl();
	
    public Login() {
        super();
      
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		String parameter1 = request.getParameter("username");
		String parameter2 = request.getParameter("password");
		
		
		if (us.login(parameter1, parameter2, request)) {
			
			request.getRequestDispatcher("index.jsp").forward(request, response);
		}else {
			request.getRequestDispatcher("login.jsp").forward(request, response);
		}
		
		
		
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
